<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('印章登记表新增及修改')" />
    <style type="text/css">
        .layui-input, .layui-textarea{width:calc(100% - 100px);}
        .layui-form-label{width:180px}
        .layui-form-select dl{margin-left:80px;min-width: calc(100% - 100px);}
        .layui-edge{margin-right:28px;}
    </style>
</head>
<body>
<form class="layui-form" id="form" style="margin: 16px 84px 16px 25px;">
	<input type="hidden" id="guid" name="guid"  th:value="${stamp?.guid}">
	<input type="hidden" id="cid" name="cid"  th:value="${stamp?.cid}">
	<input type="hidden" id="cUser" name="cUser"  th:value="${stamp?.cUser}">
	<div class="layui-form-item">
        <label class="layui-form-label"><font class="f_red">*</font>序号：</label>
        <div class="layui-input-block">
            <input type="text" name="iid" id="iid" th:value="${stamp?.iid}" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><font class="f_red">*</font>所属公司：</label>
        <div class="layui-input-block">
            <input type="text" name="cidName" id="cidName" th:value="${stamp?.cidName}" lay-verify="required" class="layui-input getMore_c" readonly>
            <i class="layui-icon layui-icon-more getMore_c" style="position: absolute;right: 35px;top: 9px;"></i>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><font class="f_red">*</font>印章类型：</label>
        <div class="layui-input-block">
            <input type="text" name="vYzLx" id="vYzLx" th:value="${stamp?.vYzLx}" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><font class="f_red">*</font>印章名称：</label>   
        <div class="layui-input-block">
        	<input type="text" name="vYzMc" id="vYzMc" th:value="${stamp?.vYzMc}" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><font class="f_red">*</font>所在办公室：</label>
        <div class="layui-input-block">
        	<input type="text" name="vBgs" id="vBgs" th:value="${stamp?.vBgs}" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><font class="f_red">*</font>保管人：</label>
        <div class="layui-input-block">
            <input type="text" name="cUserName" id="cUserName" th:value="${stamp?.cUserName}" lay-verify="required" class="layui-input getMore_u" readonly>
            <i class="layui-icon layui-icon-more getMore_u" style="position: absolute;right: 35px;top: 9px;"></i>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><font class="f_red">*</font>保管协议是否签订：</label>
        <div class="layui-input-block">
        	<input type="checkbox" th:checked="${stamp?.bbBgXy}" th:value="${stamp?.bbBgXy}?1:0" name="bbBgXy" id="bbBgXy" lay-skin="switch" lay-text="是|否">
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit="" lay-filter="btn_save" id="btn_save" value="保存">
    </div>
</form>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    /*<![CDATA[*/
    var prefix = ctx + "oa/stamp";
    /*]]>*/
</script>
<script>
var $,layer,form;
layui.use(['form','layer','jquery'], function () {
    $ = layui.$,layer = layui.layer,form = layui.form;
    form.on('switch()', function(obj){//监听开关动作
		var cChecked=obj.elem.checked?true:false,cName=obj.elem.id;
  	  	$('#'+cName).val(cChecked);
    });
});
//公司选择
$('.getMore_c').on('click', function () {
	$.modal.open('选择公司/办公室','/base/company/select','925','500',function(index){
        var res = window["layui-layer-iframe" + index].callbackdata();
        if(res=='none'){
        	$('#cid').val('');
        	$('#cidName').val('');
        	layer.close(index);
        }else{
        	$('#cid').val(res.vId);
        	$('#cidName').val(res.vName);
        	layer.close(index);
        }
    });
});
//用户选择
$('.getMore_u').on('click', function () {
	$.modal.open('选择保管人','/system/user/userselect?pagetype=radio','925','465',function(index){
		var res = window["layui-layer-iframe" + index].callbackdata();
		if(res=='none'){
			$('#cUser').val('');
			$('#cUserName').val('');
			layer.close(index);
		}else{
			$('#cUser').val(res.userId);
			$('#cUserName').val(res.userName);
			layer.close(index);
		}
	});
});
//提交调用的方法
function submitHandler() {
	var pd=[];
	pd.push($.common.formToJSON('form'));
	pd[0]['bbBgXy']=$('#bbBgXy').val();
	if($('#guid').val()){//通过判断guid是否存在来判断是新增还是保存
		if ($.validate.form()) {
            $.operate.save(prefix + "/editpost", {'stampItems':JSON.stringify(pd)});
        }
	}else{
		if ($.validate.form()) {
			$.operate.save(prefix + "/addpost", {'stampItems':JSON.stringify(pd)});
		}
	}
}
</script>
</body>
</html>
